package com.learn.container_interface;

import com.learn.container_interface.beans.service.UserService;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

public class BeanFactoryMain {
    public static void main(String[] args) {
        // 1.创建BeanFactory
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
        
        // 2.创建读取器
        XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
        
        // 3.加载配置文件
        reader.loadBeanDefinitions("container-interface.xml");
        
        // 4.通过id获取Bean实例
        UserService userService = beanFactory.getBean("userService", UserService.class);
        System.out.println(userService);
        
        /*
         * setUserDao：com.learn.ContainerInterface.beans.dao.UserDaoImpl@309e345f
         * com.learn.ContainerInterface.beans.service.UserServiceImpl@56a6d5a6
         */
    }
}
